var Locale = {
	
	current: 'en',
	
	languages: [
		['en', 'English'],
		['ru', 'Русский']
	],
	
	items: {
		'Initializing': ['Инициализация'],
		'Searching for installed software': ['Поиск установленного программного обеспечения']
			
			
	},
	
	elements: {	},
	
	langhash: { },
	
	initialize: function()
	{
		for (var i = 0; i < Locale.languages.length; i++)
		{
			Locale.langhash[i] = Locale.languages[i][0];
			Locale.langhash[Locale.languages[i][0]] = i;
		}
		
	},
	
	set: function(language)
	{
		if (Locale.current !== language)
		{
			Locale.current = language;
			for (var id in Locale.elements)
			{
				var element = document.getElementById(id);
				if (element !== null)
				{
					element.innerHTML = Locale.getInnerHtml(Locale.elements[id]);
				}
			}
		}
	},
	
	getInnerHtml: function(item)
	{
		var i = Locale.langhash[Locale.current];
		return(i == 0 ? item : Locale.items[item][i - 1]);
	},
		
	getID: function(item)
	{
		return('Locale-' + escape(item));
	},
	
	getElement: function(item)
	{
		var id = Locale.getID(item);
		var element = document.createElement('span');
		element.id = id;
		element.innerHTML = Locale.getInnerHtml(item);
		Locale.elements[id] = item;
		return(element);
	},
	
	getHtml: function(item)
	{
		var id = Locale.getID(item);
		var html = '<span id="' + id + '">' + Locale.getInnerHtml(item) + '</span>'
		Locale.elements[id] = item;
		return(html);
	}
}